import { createBrowserRouter, Navigate } from "react-router-dom";
import Route, { lazy } from "react";
import Home from '../component/Home'
import List from '../component/List'
import Login from '../component/Login'
import ZhuCe from '../component/Zhuce'
import Add from '../component/Add'
import App from '../App'

let AuthComponent = (props) => {
    let Com = props.children.type
    console.log(Com)
    if (sessionStorage.getItem('token')) {
        return <Com />
    } else {
        return <Navigate to='/login' />
    }
}


let router = createBrowserRouter([
    {
        path: '/',
        element: <App />,
        children: [
            {
                path: '/home',
                element: <Home />,
                children: [
                    {
                        path: '/home/list',
                        element: <List />
                    },

                ]
            },

        ]
    },
    {
        path: '/login',
        element: <Login />
    },
    {
        path: '/add',
        element: <Add />
    },
    {
        path: '/zhuce',
        element: <ZhuCe />
    },
])

export default router;